<?php

use Dingo\Api\Routing\Router;
use App\Commons\Utils\RouterActionPrefixTools;
use App\Admin\Controller\AdminUser\UserController;

/** @var Router $api */
$api = app(Router::class);

$api->group(['prefix' => 'admin-user'], function (Router $api) {//模块前缀

    $api->group(['prefix' => 'user'], function (Router $api) {//控制器前缀,每个控制器一个

        $rapt = new RouterActionPrefixTools(UserController::class);

        /** @see UserController::searchByQuery() 远程搜索用户列表 */
        $api->post('/search-by-query', $rapt->getAction('searchByQuery'));

        /** @see UserController::page() 用户分页列表 */
        $api->post('page', $rapt->getAction('page'));

        /** @see UserController::store() 新增用户 */
        $api->post('', $rapt->getAction('store'));

        /** @see UserController::delete() 删除用户 */
        $api->delete('/{id}', $rapt->getAction('delete'))->where('id', '[0-9]+');

        /** @see UserController::update() 修改用户 */
        $api->put('/{id}', $rapt->getAction('update'))->where('id', '[0-9]+');

        /** @see UserController::updatePassword() 修改用户密码 */
        $api->put('/{id}/password', $rapt->getAction('updatePassword'))->where('id', '[0-9]+');
    });

});